package com.huawei.xme.ch02.t15.teacher;

import com.huawei.xme.utils.BigDecimalUtil;

import java.math.BigDecimal;

/**
 * @author 黄后林
 * @date 2022-10-26 13:58:39
 * @note 程序员是用代码喂出来的
 */
public class Task02 {

    public static void main(String[] args) {

        xx(16,4);

    }

    public static BigDecimal xx(int n, int m){

        //入参检测.... TODO

        double sum =0;

        double [] array=new double[m];
        array[0]=n;


        for(int index =1;index<=array.length-1;index++){
            array[index]= Math.sqrt(array[index-1]);
        }
        System.out.println(array);

        for(int index =0;index<=array.length-1;index++){
            sum =sum+array[index];
        }

        BigDecimal rs = BigDecimalUtil.getBigDecimal(sum, 3);
        System.out.println(rs);

        return rs;


    }
}
